package recursion;

/**
 * @author yangwenqi
 * @decs TODO
 * @date 2025/5/15
 * //喝啤酒问题，一瓶啤酒2元，两个空瓶子可以换一瓶啤酒，四个啤酒盖可以换一瓶啤酒，请问10元共可以喝多少瓶？
 */

public class RecursionDemo2 {
    static int beerCap=0;
    static int beerCount=0;
    static int beerBottle=0;

    public static void main(String[] args) {
        System.out.println("10元可以买"+buyBeer(10)+"瓶啤酒");

    }
    public static int buyBeer(int money) {
        beerCount+=money/2;
        beerBottle+=money/2;
        beerCap+=money/2;
        int changeMoney=beerBottle/2*2+beerCap/4*2;
        beerBottle%=2;
        beerCap%=4;
        if(changeMoney>=2){
            buyBeer(changeMoney);
        }
        return beerCount;
    }
}
